package com.miao.controller;

import com.miao.dto.LoginDto;
import com.miao.service.UserService;
import com.miao.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Tag(name = "登陆服务")
@RestController
@RequestMapping("auth")
@CrossOrigin
public class AuthController {

    @Autowired
    private UserService userService;


    @Operation(summary = "登陆")
    @PostMapping("/login")
    public Result<Object> Login(@RequestBody LoginDto dto){
        return userService.Login(dto);
    }


    @Operation(summary = "注册")
    @PostMapping("register")
    public Result<Object> Register(@RequestBody LoginDto dto){
        return userService.Register(dto);
    }

    @GetMapping("info")
    @Operation(summary = "获取用户信息")
    public Result info(){
        return userService.info();
    }
}
